package com.xbongbong.formula.qlexpress.operator.logic;

import com.ql.util.express.Operator;
import com.xbongbong.paas.toolbox.util.StringUtil;

import java.util.Objects;

/**
 * @author: wufeng
 * @date: 2018/7/5 15:22
 * @desrcption: 判断值是否为空字符串、空对象或者空数组
 */
public class OperatorIsEmpty extends Operator {

    public OperatorIsEmpty(String name){
        this.name = name;
    }

    public OperatorIsEmpty(String aliasName, String aName, String errorInfo){
        this.aliasName = aliasName;
        this.name = aName;
        this.errorInfo = errorInfo;
    }

    /**
     * @param list 判断字符串是否为空
     * @return 为空返回true，不为空返回false
     * @throws Exception
     */
    @Override
    public Object executeInner(Object[] list) throws Exception {

        return Objects.isNull(list[0]) || StringUtil.isEmpty(list[0].toString());
    }
}

